relay5 2.2.1
Loading...
Searching...
No Matches
relay5


Relay 5 Click

Relay 5 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Mar 2023.
  • Type : I2C type

Software Support

Example Description

This example demonstrates the use of Relay 5 Click board by toggling the relays state.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Relay5

Example Key Functions

Application Init

Initializes the driver and logger.

void application_init ( void )
{
log_cfg_t log_cfg;
relay5_cfg_t relay5_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
relay5_cfg_setup( &relay5_cfg );
if ( I2C_MASTER_ERROR == relay5_init( &relay5, &relay5_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( RELAY5_ERROR == relay5_default_cfg ( &relay5 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define RELAY5_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition relay5.h:137
void application_init(void)
Definition main.c:31
#define MIKROBUS_POSITION_RELAY5
Definition main.c:25
@ RELAY5_ERROR
Definition relay5.h:185

Application Task

Switches all relays state every 5 seconds and displays the state on the USB UART.

void application_task ( void )
{
log_printf( &logger, " Relay 1 set to normally open state\r\n" );
log_printf( &logger, " Relay 2 set to normally close state\r\n" );
log_printf( &logger, " Relay 3 set to normally open state\r\n\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
log_printf( &logger, " Relay 1 set to normally close state\r\n" );
log_printf( &logger, " Relay 2 set to normally open state\r\n" );
log_printf( &logger, " Relay 3 set to normally close state\r\n\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
err_t relay5_set_relay3_close(relay5_t *ctx)
Relay 5 set relay 3 close function.
err_t relay5_set_relay2_close(relay5_t *ctx)
Relay 5 set relay 2 close function.
err_t relay5_set_relay2_open(relay5_t *ctx)
Relay 5 set relay 2 open function.
err_t relay5_set_relay3_open(relay5_t *ctx)
Relay 5 set relay 3 open function.
void application_task(void)
Definition main.c:67

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.